﻿Imports System.Data.SqlClient

Public Class BackupDatabase
    Public Shared Function BackUpDatabase(ByVal dbName As String, ByVal fileName As String, ByVal type As String) As Boolean
        Dim bol As Boolean = True
        Try

            Dim cmd As SqlCommand = New SqlCommand("BackUp Database " & dbName & " To Disk = '" & fileName & "' With " & type, Dbinterface.Connection)
            cmd.ExecuteNonQuery()

        Catch ex As Exception
            bol = False

        End Try
        Return bol
    End Function
    
    Public Shared Sub getAllDatabase(cbo As ComboBox)
        'Get All database from server 
        Str = "SELECT NAME FROM master..sysdatabases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')"
        cbo.DisplayMember = "NAME"
        cbo.ValueMember = "NAME"
        Dim dt = CmdText.ExecuteDataTable(Str)
        cbo.DataSource = dt
    End Sub
End Class
